import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginVue from "eslint-plugin-vue";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

export default [
  {
    // 配置需要被忽略的文件，替代之前的 .eslintignore 文件
    ignores: ["**/dist/","node_modules", "docs/"],
  },
  {
    files: ["**/*.{js,mjs,cjs,ts,vue}"]
  },
  {
    languageOptions: 
    { globals: {...globals.browser, ...globals.node} }
  },
  pluginJs.configs.recommended,
  ...tseslint.configs.recommended,
  ...pluginVue.configs["flat/recommended"],
  eslintPluginPrettierRecommended,
  {
    files: ["**/*.vue"], 
    languageOptions: {
      parserOptions: {
        parser: tseslint.parser
      }
    },
    // "off"或者 - 关闭规则0
    // "warn"或者 - 将规则作为警告打开（不影响退出代码）1
    // "error"或者 - 将规则作为错误打开（退出代码将为 1）2
    rules: {
      // vue
      "vue/multi-word-component-names": 0,
      "no-async-promise-executor": 0,
    },
  },
  /**
   * typescript 规则
   */
  {
    files: ["**/*.{ts,tsx,vue}"],
    rules: {
      "@typescript-eslint/no-explicit-any": "off",
      "@typescript-eslint/no-empty-object-type": "off",
    },
  },
];